package juc.day03;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] X = sc.next().toCharArray();
        char[] Y = sc.next().toCharArray();
        int m = X.length;
        int n = Y.length;
        int[][] dp = new int[m+1][n+1];    // 备忘录。dp[i][j]含义：X[1..i]和Y[1..j]中，以Xi和Yi结尾的最长公共子串Z[1..l]的长度
        int max = 0;
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                if(X[i-1] == Y[j-1]){
                    dp[i][j] = dp[i-1][j-1] + 1;
                    if(max < dp[i][j]){
                        max = dp[i][j];
                    }
                }
            }
        }
        System.out.println(max);
    }
}
